package com.controller;

import com.pojo.ShopCommentReply;
import com.service.ShopCommentReplyService;
import com.util.ServerResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2020/3/20.
 */
@Api(tags = "用户店铺点评回应API")
@Controller
public class ShopCommentReplyController {
    @Autowired
    private ShopCommentReplyService shopCommentReplyService;
    @ApiOperation(value ="创建用户店铺点评回应",notes ="" )
    @PostMapping("/shopCommentReply")
    @ResponseBody
    public ServerResponse add(ShopCommentReply shopCommentReply){
        // ServerResponse serverResponse =
        //System.out.println("serverResponse:"+serverResponse);
        return shopCommentReplyService.save(shopCommentReply);
    }

    @ApiOperation(value = "根据用户店铺点评回应的id删除回应",notes ="")
    @DeleteMapping("/shopCommentReply/{id}")
    @ResponseBody
    public ServerResponse del(@PathVariable("id")String id){
        ServerResponse serverResponse = shopCommentReplyService.modifyStatus(Integer.valueOf(id));
        System.out.println("serverResponse:"+serverResponse);
        return serverResponse;
    }
    @ApiOperation(value ="修改用户店铺点评回应",notes ="" )
    @PutMapping("/shopCommentReply")
    @ResponseBody
    public ServerResponse upd(ShopCommentReply shopCommentReply){
        System.out.println(shopCommentReply);
        ServerResponse serverResponse = shopCommentReplyService.modify(shopCommentReply);
        return serverResponse;
    }
    /*
      根据id查询用户
   */
    @ApiOperation(value ="根据用户id查询点评回应")
    @GetMapping("/shopCommentReply/{id}")
    @ResponseBody
    public ServerResponse findById(@PathVariable("id") String id){
        System.out.println(id);
        ServerResponse serverResponse = shopCommentReplyService.getById(Integer.valueOf(id));
        return serverResponse;
    }

    @ApiOperation(value ="查询所有点评回应 信息")
    @GetMapping("/shopCommentReply")
    public String findAll(Model model){
        ServerResponse serverResponse = shopCommentReplyService.getAll();
        model.addAttribute("info",serverResponse.getData());
        return "back/shop/shopCommentReply";
    }
}
